package com.adinall.dsp.core.poi.excel;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;

public abstract class Excel {

    protected XSSFRow getRow(XSSFSheet sheet, int rownum) {

        XSSFRow row = sheet.getRow(rownum);

        if (row == null) {
            row = sheet.createRow(rownum);
        }

        return row;
    }

    protected XSSFCell getCell(XSSFSheet sheet, int rownum, int columnIndex) {

        XSSFRow row = getRow(sheet, rownum);

        XSSFCell cell = row.getCell(columnIndex);

        if (cell == null) {
            cell = row.createCell(columnIndex);
        }

        return cell;
    }
}
